package com.example.productionforpeopleapplication

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

/**
 * 起始页
 * */
class SplashActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    enableEdgeToEdge()
    setContentView(R.layout.activity_splash)
    window.setBackgroundDrawable(null)
    ViewCompat.setOnApplyWindowInsetsListener(
      findViewById(R.id.main)
    ) { v: View, insets: WindowInsetsCompat ->
      val systemBars =
        insets.getInsets(WindowInsetsCompat.Type.systemBars())
      v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
      insets
    }
    setStatus()
    enterMainActivity()
  }

  private fun enterMainActivity() {
    Handler(mainLooper).postDelayed({
      startActivity(Intent(this, MainActivity::class.java))
    }, 1 * 1000)
  }

  private fun setStatus() { // 设置为全面屏
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//      window.statusBarColor = resources.getColor(R.color.red)
//      window.navigationBarColor = resources.getColor(R.color.red)
    }
    window.decorView.systemUiVisibility =
//      View.SYSTEM_UI_FLAG_FULLSCREEN or
      View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
          View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
          View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
          View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
  }
}